<?php

use database\model\base;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;


class BaseTables extends Migration
{

    private $tables;


    function __construct()
    {
        $this->tables=base::GetAllModels();
    }


    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //
        foreach($this->tables as $t)
        {
            Schema::dropIfExists($t->table);
            Schema::create($t->table, function (Blueprint $table)use ($t) {
                $t->CreateFileds($table);
            });
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
        foreach($this->tables as $t)
        {
            Schema::dropIfExists($t->table);
        }
    }
}
